<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE GHCForeignImportPrim #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE UnliftedFFITypes #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE MagicHash #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LANGUAGE UnboxedTuples #-}</span><span>
</span><span id="line-5"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude #-}</span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# LANGUAGE EmptyCase #-}</span><span>
</span><span id="line-7"></span><span>
</span><span id="line-8"></span><span class="hs-comment">-- | Primitive exceptions.</span><span>
</span><span id="line-9"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Prim.Exception</span><span>
</span><span id="line-10"></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Prim.Exception.html#raiseOverflow"><span class="hs-identifier">raiseOverflow</span></a></span><span>
</span><span id="line-11"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Prim.Exception.html#raiseUnderflow"><span class="hs-identifier">raiseUnderflow</span></a></span><span>
</span><span id="line-12"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Prim.Exception.html#raiseDivZero"><span class="hs-identifier">raiseDivZero</span></a></span><span>
</span><span id="line-13"></span><span>   </span><span class="hs-special">)</span><span>
</span><span id="line-14"></span><span class="hs-keyword">where</span><span>
</span><span id="line-15"></span><span>
</span><span id="line-16"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prim.html"><span class="hs-identifier">GHC.Prim</span></a></span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Magic.html"><span class="hs-identifier">GHC.Magic</span></a></span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">default</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Double and Integer aren't available yet</span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span class="hs-comment">-- Note [Arithmetic exceptions]</span><span>
</span><span id="line-22"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-23"></span><span class="hs-comment">--</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- ghc-prim provides several functions to raise arithmetic exceptions</span><span>
</span><span id="line-25"></span><span class="hs-comment">-- (raiseDivZero, raiseUnderflow, raiseOverflow) that are wired-in the RTS.</span><span>
</span><span id="line-26"></span><span class="hs-comment">-- These exceptions are meant to be used by the package implementing arbitrary</span><span>
</span><span id="line-27"></span><span class="hs-comment">-- precision numbers (Natural,Integer). It can't depend on `base` package to</span><span>
</span><span id="line-28"></span><span class="hs-comment">-- raise exceptions in a normal way because it would create a dependency</span><span>
</span><span id="line-29"></span><span class="hs-comment">-- cycle (base &lt;-&gt; bignum package). See #14664</span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">prim</span></span><span> </span><span class="annot"><span class="hs-string">&quot;stg_raiseOverflowzh&quot;</span></span><span> </span><span id="raiseOverflow%23"><span class="annot"><a href="GHC.Prim.Exception.html#raiseOverflow%23"><span class="hs-identifier hs-var">raiseOverflow#</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Prim.html#State%23"><span class="hs-identifier hs-type">State#</span></a></span><span> </span><span class="annot"><a href="GHC.Prim.html#RealWorld"><span class="hs-identifier hs-type">RealWorld</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><a href="GHC.Prim.html#State%23"><span class="hs-identifier hs-type">State#</span></a></span><span> </span><span class="annot"><a href="GHC.Prim.html#RealWorld"><span class="hs-identifier hs-type">RealWorld</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Prim.html#Void%23"><span class="hs-identifier hs-type">Void#</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-32"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">prim</span></span><span> </span><span class="annot"><span class="hs-string">&quot;stg_raiseUnderflowzh&quot;</span></span><span> </span><span id="raiseUnderflow%23"><span class="annot"><a href="GHC.Prim.Exception.html#raiseUnderflow%23"><span class="hs-identifier hs-var">raiseUnderflow#</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Prim.html#State%23"><span class="hs-identifier hs-type">State#</span></a></span><span> </span><span class="annot"><a href="GHC.Prim.html#RealWorld"><span class="hs-identifier hs-type">RealWorld</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><a href="GHC.Prim.html#State%23"><span class="hs-identifier hs-type">State#</span></a></span><span> </span><span class="annot"><a href="GHC.Prim.html#RealWorld"><span class="hs-identifier hs-type">RealWorld</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Prim.html#Void%23"><span class="hs-identifier hs-type">Void#</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-33"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">prim</span></span><span> </span><span class="annot"><span class="hs-string">&quot;stg_raiseDivZZerozh&quot;</span></span><span> </span><span id="raiseDivZero%23"><span class="annot"><a href="GHC.Prim.Exception.html#raiseDivZero%23"><span class="hs-identifier hs-var">raiseDivZero#</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Prim.html#State%23"><span class="hs-identifier hs-type">State#</span></a></span><span> </span><span class="annot"><a href="GHC.Prim.html#RealWorld"><span class="hs-identifier hs-type">RealWorld</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><a href="GHC.Prim.html#State%23"><span class="hs-identifier hs-type">State#</span></a></span><span> </span><span class="annot"><a href="GHC.Prim.html#RealWorld"><span class="hs-identifier hs-type">RealWorld</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Prim.html#Void%23"><span class="hs-identifier hs-type">Void#</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="hs-comment">-- We give a bottoming demand signature to 'raiseOverflow', 'raiseUnderflow' and</span><span>
</span><span id="line-36"></span><span class="hs-comment">-- 'raiseDivZero' in &quot;GHC.Core.Make&quot;. NOINLINE pragmas are necessary because if</span><span>
</span><span id="line-37"></span><span class="hs-comment">-- we ever inlined them we would lose that information.</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span class="hs-comment">-- | Raise 'GHC.Exception.Type.overflowException'</span><span>
</span><span id="line-40"></span><span id="local-6989586621679074155"><span class="annot"><a href="GHC.Prim.Exception.html#raiseOverflow"><span class="hs-identifier hs-type">raiseOverflow</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679074155"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-41"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.Prim.Exception.html#raiseOverflow"><span class="hs-pragma hs-type">raiseOverflow</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-42"></span><span id="raiseOverflow"><span class="annot"><span class="annottext">raiseOverflow :: forall a. a
</span><a href="GHC.Prim.Exception.html#raiseOverflow"><span class="hs-identifier hs-var hs-var">raiseOverflow</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(State# RealWorld -&gt; a) -&gt; a
forall o. (State# RealWorld -&gt; o) -&gt; o
</span><a href="GHC.Magic.html#runRW%23"><span class="hs-identifier hs-var">runRW#</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679074143"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679074143"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">State# RealWorld -&gt; (# State# RealWorld, Void# #)
</span><a href="GHC.Prim.Exception.html#raiseOverflow%23"><span class="hs-identifier hs-var">raiseOverflow#</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679074143"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Void#
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679074142"><span class="annot"><span class="annottext">x :: t
</span><a href="#local-6989586621679074142"><span class="hs-identifier hs-var hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679074142"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">a
forall a. a
</span><a href="#local-6989586621679074142"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span class="hs-comment">-- | Raise 'GHC.Exception.Type.underflowException'</span><span>
</span><span id="line-45"></span><span id="local-6989586621679074141"><span class="annot"><a href="GHC.Prim.Exception.html#raiseUnderflow"><span class="hs-identifier hs-type">raiseUnderflow</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679074141"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-46"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.Prim.Exception.html#raiseUnderflow"><span class="hs-pragma hs-type">raiseUnderflow</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-47"></span><span id="raiseUnderflow"><span class="annot"><span class="annottext">raiseUnderflow :: forall a. a
</span><a href="GHC.Prim.Exception.html#raiseUnderflow"><span class="hs-identifier hs-var hs-var">raiseUnderflow</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(State# RealWorld -&gt; a) -&gt; a
forall o. (State# RealWorld -&gt; o) -&gt; o
</span><a href="GHC.Magic.html#runRW%23"><span class="hs-identifier hs-var">runRW#</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679074140"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679074140"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">State# RealWorld -&gt; (# State# RealWorld, Void# #)
</span><a href="GHC.Prim.Exception.html#raiseUnderflow%23"><span class="hs-identifier hs-var">raiseUnderflow#</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679074140"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Void#
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679074139"><span class="annot"><span class="annottext">x :: t
</span><a href="#local-6989586621679074139"><span class="hs-identifier hs-var hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679074139"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">a
forall a. a
</span><a href="#local-6989586621679074139"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="hs-comment">-- | Raise 'GHC.Exception.Type.divZeroException'</span><span>
</span><span id="line-50"></span><span id="local-6989586621679074138"><span class="annot"><a href="GHC.Prim.Exception.html#raiseDivZero"><span class="hs-identifier hs-type">raiseDivZero</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679074138"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-51"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.Prim.Exception.html#raiseDivZero"><span class="hs-pragma hs-type">raiseDivZero</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-52"></span><span id="raiseDivZero"><span class="annot"><span class="annottext">raiseDivZero :: forall a. a
</span><a href="GHC.Prim.Exception.html#raiseDivZero"><span class="hs-identifier hs-var hs-var">raiseDivZero</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(State# RealWorld -&gt; a) -&gt; a
forall o. (State# RealWorld -&gt; o) -&gt; o
</span><a href="GHC.Magic.html#runRW%23"><span class="hs-identifier hs-var">runRW#</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679074137"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679074137"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">State# RealWorld -&gt; (# State# RealWorld, Void# #)
</span><a href="GHC.Prim.Exception.html#raiseDivZero%23"><span class="hs-identifier hs-var">raiseDivZero#</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679074137"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Void#
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679074136"><span class="annot"><span class="annottext">x :: t
</span><a href="#local-6989586621679074136"><span class="hs-identifier hs-var hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679074136"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">a
forall a. a
</span><a href="#local-6989586621679074136"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-53"></span></pre></body></html>